package com.danny.login

import android.app.Activity
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import com.danny.componentbase.service.IAccountService

class AccountService: IAccountService {
    override fun isLogin(): Boolean {
        return AccountUtils.userInfo != null
    }

    override fun getAccountId(): String? {
        return if (AccountUtils.userInfo == null) null else AccountUtils.userInfo!!.accountId
    }

    override fun newUserFragment(activity: Activity,
                                 containerId: Int,
                                 manager: FragmentManager,
                                 bundle: Bundle?,
                                 tag: String): Fragment? {
        var transaction = manager.beginTransaction()
        var userFragment = UserFragment()
        transaction.add(containerId,userFragment,tag)
        transaction.commit()
        return userFragment
    }
}